try:
import evidently
except:
!pip install git+https://github.com/evidentlyai/evidently.git
Collecting git+https://github.com/evidentlyai/evidently.git
Cloning https://github.com/evidentlyai/evidently.git to /tmp/pip-req-build-xkbl7byo
Running command git clone --filter=blob:none --quiet https://github.com/evidentlyai/evidently.git /tmp/pip-req-build-xkbl7byo
Resolved https://github.com/evidentlyai/evidently.git to commit 725f2679db5ea4e865009577f530702ec0e04fbd
Preparing metadata (setup.py) ... done
Requirement already satisfied: plotly>=5.10.0 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (5.15.0)
Requirement already satisfied: statsmodels>=0.12.2 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (0.14.2)
Requirement already satisfied: scikit-learn>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (1.3.2)
Requirement already satisfied: pandas>=1.3.5 in /usr/local/lib/python3.10/dist-packages (from pandas[parquet]>=1.3.5->evidently==0.4.35) (2.1.4)
Requirement already satisfied: numpy>=1.22.0 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (1.26.4)
Requirement already satisfied: nltk>=3.6.7 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (3.8.1)
Requirement already satisfied: scipy>=1.10.0 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (1.13.1)
Requirement already satisfied: requests>=2.32.0 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (2.32.3)
Requirement already satisfied: PyYAML>=5.4 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (6.0.2)
Requirement already satisfied: pydantic>=1.10.13 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (2.8.2)
Collecting litestar>=2.8.3 (from evidently==0.4.35)
Downloading litestar-2.10.0-py3-none-any.whl.metadata (103 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 103.1/103.1 kB 6.0 MB/s eta 0:00:00
Collecting typing-inspect>=0.9.0 (from evidently==0.4.35)
Downloading typing_inspect-0.9.0-py3-none-any.whl.metadata (1.5 kB)
Collecting uvicorn>=0.22.0 (from uvicorn[standard]>=0.22.0->evidently==0.4.35)
Downloading uvicorn-0.30.6-py3-none-any.whl.metadata (6.6 kB)
Collecting watchdog>=3.0.0 (from evidently==0.4.35)
Downloading watchdog-4.0.2-py3-none-manylinux2014_x86_64.whl.metadata (38 kB)
Requirement already satisfied: typer>=0.3 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (0.12.3)
Requirement already satisfied: rich>=13 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (13.7.1)
Collecting iterative-telemetry>=0.0.5 (from evidently==0.4.35)
Downloading iterative_telemetry-0.0.8-py3-none-any.whl.metadata (4.1 kB)
Collecting dynaconf>=3.2.4 (from evidently==0.4.35)
Downloading dynaconf-3.2.6-py2.py3-none-any.whl.metadata (9.1 kB)
Requirement already satisfied: certifi>=2024.7.4 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (2024.7.4)
Requirement already satisfied: urllib3>=1.26.19 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (2.0.7)
Requirement already satisfied: fsspec>=2024.2.0 in /usr/local/lib/python3.10/dist-packages (from evidently==0.4.35) (2024.6.1)
Collecting ujson>=5.4.0 (from evidently==0.4.35)
Downloading ujson-5.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (9.3 kB)
Collecting deprecation>=2.1.0 (from evidently==0.4.35)
Downloading deprecation-2.1.0-py2.py3-none-any.whl.metadata (4.6 kB)
Collecting opentelemetry-api>=1.25.0 (from evidently==0.4.35)
Downloading opentelemetry_api-1.26.0-py3-none-any.whl.metadata (1.4 kB)
Collecting opentelemetry-sdk>=1.25.0 (from evidently==0.4.35)
Downloading opentelemetry_sdk-1.26.0-py3-none-any.whl.metadata (1.5 kB)
Collecting opentelemetry-proto>=1.25.0 (from evidently==0.4.35)
Downloading opentelemetry_proto-1.26.0-py3-none-any.whl.metadata (2.3 kB)
Collecting opentelemetry-exporter-otlp-proto-grpc>=1.25.0 (from evidently==0.4.35)
Downloading opentelemetry_exporter_otlp_proto_grpc-1.26.0-py3-none-any.whl.metadata (2.3 kB)
Collecting opentelemetry-exporter-otlp-proto-http>=1.25.0 (from evidently==0.4.35)
Downloading opentelemetry_exporter_otlp_proto_http-1.26.0-py3-none-any.whl.metadata (2.3 kB)
Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from deprecation>=2.1.0->evidently==0.4.35) (24.1)
Collecting appdirs (from iterative-telemetry>=0.0.5->evidently==0.4.35)
Downloading appdirs-1.4.4-py2.py3-none-any.whl.metadata (9.0 kB)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from iterative-telemetry>=0.0.5->evidently==0.4.35) (3.15.4)
Requirement already satisfied: distro in /usr/lib/python3/dist-packages (from iterative-telemetry>=0.0.5->evidently==0.4.35) (1.7.0)
Requirement already satisfied: anyio>=3 in /usr/local/lib/python3.10/dist-packages (from litestar>=2.8.3->evidently==0.4.35) (3.7.1)
Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from litestar>=2.8.3->evidently==0.4.35) (8.1.7)
Requirement already satisfied: exceptiongroup in /usr/local/lib/python3.10/dist-packages (from litestar>=2.8.3->evidently==0.4.35) (1.2.2)
Collecting httpx>=0.22 (from litestar>=2.8.3->evidently==0.4.35)
Downloading httpx-0.27.0-py3-none-any.whl.metadata (7.2 kB)
Collecting msgspec>=0.18.2 (from litestar>=2.8.3->evidently==0.4.35)
Downloading msgspec-0.18.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.9 kB)
Requirement already satisfied: multidict>=6.0.2 in /usr/local/lib/python3.10/dist-packages (from litestar>=2.8.3->evidently==0.4.35) (6.0.5)
Collecting polyfactory>=2.6.3 (from litestar>=2.8.3->evidently==0.4.35)
Downloading polyfactory-2.16.2-py3-none-any.whl.metadata (27 kB)
Collecting rich-click (from litestar>=2.8.3->evidently==0.4.35)
Downloading rich_click-1.8.3-py3-none-any.whl.metadata (7.9 kB)
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from litestar>=2.8.3->evidently==0.4.35) (4.12.2)
Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk>=3.6.7->evidently==0.4.35) (1.4.2)
Requirement already satisfied: regex>=2021.8.3 in /usr/local/lib/python3.10/dist-packages (from nltk>=3.6.7->evidently==0.4.35) (2024.5.15)
Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from nltk>=3.6.7->evidently==0.4.35) (4.66.5)
Collecting deprecated>=1.2.6 (from opentelemetry-api>=1.25.0->evidently==0.4.35)
Downloading Deprecated-1.2.14-py2.py3-none-any.whl.metadata (5.4 kB)
Collecting importlib-metadata<=8.0.0,>=6.0 (from opentelemetry-api>=1.25.0->evidently==0.4.35)
Downloading importlib_metadata-8.0.0-py3-none-any.whl.metadata (4.6 kB)
Requirement already satisfied: googleapis-common-protos~=1.52 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.25.0->evidently==0.4.35) (1.63.2)
Requirement already satisfied: grpcio<2.0.0,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-exporter-otlp-proto-grpc>=1.25.0->evidently==0.4.35) (1.64.1)
Collecting opentelemetry-exporter-otlp-proto-common==1.26.0 (from opentelemetry-exporter-otlp-proto-grpc>=1.25.0->evidently==0.4.35)
Downloading opentelemetry_exporter_otlp_proto_common-1.26.0-py3-none-any.whl.metadata (1.8 kB)
Requirement already satisfied: protobuf<5.0,>=3.19 in /usr/local/lib/python3.10/dist-packages (from opentelemetry-proto>=1.25.0->evidently==0.4.35) (3.20.3)
Collecting opentelemetry-semantic-conventions==0.47b0 (from opentelemetry-sdk>=1.25.0->evidently==0.4.35)
Downloading opentelemetry_semantic_conventions-0.47b0-py3-none-any.whl.metadata (2.4 kB)
Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.3.5->pandas[parquet]>=1.3.5->evidently==0.4.35) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.3.5->pandas[parquet]>=1.3.5->evidently==0.4.35) (2024.1)
Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.3.5->pandas[parquet]>=1.3.5->evidently==0.4.35) (2024.1)
Requirement already satisfied: pyarrow>=7.0.0 in /usr/local/lib/python3.10/dist-packages (from pandas[parquet]>=1.3.5->evidently==0.4.35) (14.0.2)
Requirement already satisfied: tenacity>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from plotly>=5.10.0->evidently==0.4.35) (9.0.0)
Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=1.10.13->evidently==0.4.35) (0.7.0)
Requirement already satisfied: pydantic-core==2.20.1 in /usr/local/lib/python3.10/dist-packages (from pydantic>=1.10.13->evidently==0.4.35) (2.20.1)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.0->evidently==0.4.35) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.32.0->evidently==0.4.35) (3.7)
Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich>=13->evidently==0.4.35) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich>=13->evidently==0.4.35) (2.16.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=1.0.1->evidently==0.4.35) (3.5.0)
Requirement already satisfied: patsy>=0.5.6 in /usr/local/lib/python3.10/dist-packages (from statsmodels>=0.12.2->evidently==0.4.35) (0.5.6)
Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from typer>=0.3->evidently==0.4.35) (1.5.4)
Collecting mypy-extensions>=0.3.0 (from typing-inspect>=0.9.0->evidently==0.4.35)
Downloading mypy_extensions-1.0.0-py3-none-any.whl.metadata (1.1 kB)
Collecting h11>=0.8 (from uvicorn>=0.22.0->uvicorn[standard]>=0.22.0->evidently==0.4.35)
Downloading h11-0.14.0-py3-none-any.whl.metadata (8.2 kB)
Collecting httptools>=0.5.0 (from uvicorn[standard]>=0.22.0->evidently==0.4.35)
Downloading httptools-0.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.6 kB)
Collecting python-dotenv>=0.13 (from uvicorn[standard]>=0.22.0->evidently==0.4.35)
Downloading python_dotenv-1.0.1-py3-none-any.whl.metadata (23 kB)
Collecting uvloop!=0.15.0,!=0.15.1,>=0.14.0 (from uvicorn[standard]>=0.22.0->evidently==0.4.35)
Downloading uvloop-0.19.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.9 kB)
Collecting watchfiles>=0.13 (from uvicorn[standard]>=0.22.0->evidently==0.4.35)
Downloading watchfiles-0.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.9 kB)
Collecting websockets>=10.4 (from uvicorn[standard]>=0.22.0->evidently==0.4.35)
Downloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.6 kB)
Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.10/dist-packages (from anyio>=3->litestar>=2.8.3->evidently==0.4.35) (1.3.1)
Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.10/dist-packages (from deprecated>=1.2.6->opentelemetry-api>=1.25.0->evidently==0.4.35) (1.16.0)
Collecting httpcore==1.* (from httpx>=0.22->litestar>=2.8.3->evidently==0.4.35)
Downloading httpcore-1.0.5-py3-none-any.whl.metadata (20 kB)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.10/dist-packages (from importlib-metadata<=8.0.0,>=6.0->opentelemetry-api>=1.25.0->evidently==0.4.35) (3.19.2)
Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich>=13->evidently==0.4.35) (0.1.2)
Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from patsy>=0.5.6->statsmodels>=0.12.2->evidently==0.4.35) (1.16.0)
Collecting faker (from polyfactory>=2.6.3->litestar>=2.8.3->evidently==0.4.35)
Downloading Faker-27.0.0-py3-none-any.whl.metadata (15 kB)
Downloading deprecation-2.1.0-py2.py3-none-any.whl (11 kB)
Downloading dynaconf-3.2.6-py2.py3-none-any.whl (231 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 231.1/231.1 kB 9.6 MB/s eta 0:00:00
Downloading iterative_telemetry-0.0.8-py3-none-any.whl (10 kB)
Downloading litestar-2.10.0-py3-none-any.whl (531 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 531.5/531.5 kB 24.4 MB/s eta 0:00:00
Downloading opentelemetry_api-1.26.0-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 3.4 MB/s eta 0:00:00
Downloading opentelemetry_exporter_otlp_proto_grpc-1.26.0-py3-none-any.whl (18 kB)
Downloading opentelemetry_proto-1.26.0-py3-none-any.whl (52 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.5/52.5 kB 3.0 MB/s eta 0:00:00
Downloading opentelemetry_exporter_otlp_proto_common-1.26.0-py3-none-any.whl (17 kB)
Downloading opentelemetry_exporter_otlp_proto_http-1.26.0-py3-none-any.whl (16 kB)
Downloading opentelemetry_sdk-1.26.0-py3-none-any.whl (109 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 109.5/109.5 kB 8.2 MB/s eta 0:00:00
Downloading opentelemetry_semantic_conventions-0.47b0-py3-none-any.whl (138 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 138.0/138.0 kB 8.9 MB/s eta 0:00:00
Downloading typing_inspect-0.9.0-py3-none-any.whl (8.8 kB)
Downloading ujson-5.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (53 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.6/53.6 kB 4.2 MB/s eta 0:00:00
Downloading uvicorn-0.30.6-py3-none-any.whl (62 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.8/62.8 kB 5.1 MB/s eta 0:00:00
Downloading watchdog-4.0.2-py3-none-manylinux2014_x86_64.whl (82 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 82.9/82.9 kB 5.6 MB/s eta 0:00:00
Downloading Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB)
Downloading h11-0.14.0-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 4.4 MB/s eta 0:00:00
Downloading httptools-0.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (341 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 341.4/341.4 kB 22.1 MB/s eta 0:00:00
Downloading httpx-0.27.0-py3-none-any.whl (75 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.6/75.6 kB 4.1 MB/s eta 0:00:00
Downloading httpcore-1.0.5-py3-none-any.whl (77 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.9/77.9 kB 5.6 MB/s eta 0:00:00
Downloading importlib_metadata-8.0.0-py3-none-any.whl (24 kB)
Downloading msgspec-0.18.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (210 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 210.3/210.3 kB 14.1 MB/s eta 0:00:00
Downloading mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)
Downloading polyfactory-2.16.2-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 4.6 MB/s eta 0:00:00
Downloading python_dotenv-1.0.1-py3-none-any.whl (19 kB)
Downloading uvloop-0.19.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.4/3.4 MB 51.7 MB/s eta 0:00:00
Downloading watchfiles-0.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (427 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 427.7/427.7 kB 21.7 MB/s eta 0:00:00
Downloading websockets-12.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (130 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 130.2/130.2 kB 7.1 MB/s eta 0:00:00
Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Downloading rich_click-1.8.3-py3-none-any.whl (35 kB)
Downloading Faker-27.0.0-py3-none-any.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 39.8 MB/s eta 0:00:00
Building wheels for collected packages: evidently
Building wheel for evidently (setup.py) ... done
Created wheel for evidently: filename=evidently-0.4.35-py3-none-any.whl size=3407805 sha256=8f2e9945d9b39ff549de7548abcc8c091ac7b280826923ccba5dd89c89c9896a
Stored in directory: /tmp/pip-ephem-wheel-cache-brq72rut/wheels/b9/63/7b/170638c7d0b5772f1e76c1d9adefc91eee2697a23b337135e0
Successfully built evidently
Installing collected packages: appdirs, websockets, watchdog, uvloop, ujson, python-dotenv, opentelemetry-proto, mypy-extensions, msgspec, importlib-metadata, httptools, h11, dynaconf, deprecation, deprecated, watchfiles, uvicorn, typing-inspect, opentelemetry-exporter-otlp-proto-common, opentelemetry-api, iterative-telemetry, httpcore, faker, rich-click, polyfactory, opentelemetry-semantic-conventions, httpx, opentelemetry-sdk, litestar, opentelemetry-exporter-otlp-proto-http, opentelemetry-exporter-otlp-proto-grpc, evidently
Attempting uninstall: importlib-metadata
Found existing installation: importlib_metadata 8.2.0
Uninstalling importlib_metadata-8.2.0:
Successfully uninstalled importlib_metadata-8.2.0
Successfully installed appdirs-1.4.4 deprecated-1.2.14 deprecation-2.1.0 dynaconf-3.2.6 evidently-0.4.35 faker-27.0.0 h11-0.14.0 httpcore-1.0.5 httptools-0.6.1 httpx-0.27.0 importlib-metadata-8.0.0 iterative-telemetry-0.0.8 litestar-2.10.0 msgspec-0.18.6 mypy-extensions-1.0.0 opentelemetry-api-1.26.0 opentelemetry-exporter-otlp-proto-common-1.26.0 opentelemetry-exporter-otlp-proto-grpc-1.26.0 opentelemetry-exporter-otlp-proto-http-1.26.0 opentelemetry-proto-1.26.0 opentelemetry-sdk-1.26.0 opentelemetry-semantic-conventions-0.47b0 polyfactory-2.16.2 python-dotenv-1.0.1 rich-click-1.8.3 typing-inspect-0.9.0 ujson-5.10.0 uvicorn-0.30.6 uvloop-0.19.0 watchdog-4.0.2 watchfiles-0.23.0 websockets-12.0
from google.colab import drive
drive.mount('/content/drive')
Mounted at /content/drive
from evidently import ColumnMapping
from evidently.report import Report
from evidently.metric_preset import DataDriftPreset, ClassificationPreset
from evidently.metrics import ClassificationQualityMetric, DataDriftTable, DatasetDriftMetric
import pandas as pd
import numpy as np
# Define the path to the datasets
train_path = '/content/drive/My Drive/ML Ops/final_model_monitor/train_data.csv'
test_path = '/content/drive/My Drive/ML Ops/final_model_monitor/test_data.csv'
test_adj_path = '/content/drive/My Drive/ML Ops/final_model_monitor/test_data_adj.csv'
# Load the dataset
train = pd.read_csv(train_path)
test = pd.read_csv(test_path)
test_adj = pd.read_csv(test_adj_path)
# Tweak Target Column Name for Similarity and remove unneeded columns
train.rename(columns={'y_train_pred': 'Conversion_Pred'}, inplace=True)
test.rename(columns={'y_test_pred': 'Conversion_Pred'}, inplace=True)
test_adj.rename(columns={'y_test_adj_pred': 'Conversion_Pred'}, inplace=True)
train.drop(columns=['CustomerID','AdvertisingPlatform','AdvertisingTool'], inplace=True)
test.drop(columns=['CustomerID','AdvertisingPlatform','AdvertisingTool'], inplace=True)
test_adj.drop(columns=['CustomerID','AdvertisingPlatform','AdvertisingTool'], inplace=True)
train['Conversion'] = train['Conversion'].astype(int)
train['Conversion_Pred'] = train['Conversion_Pred'].astype(int)
test['Conversion'] = test['Conversion'].astype(int)
test['Conversion_Pred'] = test['Conversion_Pred'].astype(int)
test_adj['Conversion'] = test_adj['Conversion'].astype(int)
test_adj['Conversion_Pred'] = test_adj['Conversion_Pred'].astype(int)
# Define numerical and categorical features
numerical_features = train.select_dtypes(include=['float64', 'int64']).columns.tolist()
categorical_features = train.select_dtypes(include=['object']).columns.tolist()
# Define column mapping
column_mapping = ColumnMapping()
column_mapping.target = 'Conversion'
column_mapping.prediction = 'Conversion_Pred'
column_mapping.numerical_features = numerical_features
column_mapping.categorical_features = categorical_features
# Generate reports
report_original = Report(metrics=[ClassificationQualityMetric(), DataDriftPreset()])
report_original.run(reference_data=train, current_data=test, column_mapping=column_mapping)
report_original.show()
We will now run the adjusted data through, which we would expect to see a decrease in model performance and hopefully the features are flagged by Evidently as drifting.
# Generate reports
report_adjusted = Report(metrics=[ClassificationQualityMetric(), DataDriftPreset()])
report_adjusted.run(reference_data=train, current_data=test_adj, column_mapping=column_mapping)
report_adjusted.show()